package SwingThread;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import javax.swing.Timer;

public class SwingDemo extends JFrame {
	private static final long serialVersionUID = 1L;
	private JProgressBar progressBar = new JProgressBar();
	private JTextField text = new JTextField(10);
	
	private int count = 0;

	public SwingDemo() {
		this.setLayout(new FlowLayout());
		add(progressBar);
		add(text);
		text.setText("good");
		text.setEditable(true);
		Timer timer = new Timer(500, new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				count++;
				System.out.println(count);
				 progressBar.setValue(count);
				if (count % 2 == 0) {
					text.setText("进行中...............");
				} else {
					text.setText(".............进行中");
				}
				
			}
		});
		timer.start();
	}

	public static void main(String[] args) {

		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SwingDemo fg = new SwingDemo();
					fg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
					fg.setSize(300, 100);
					fg.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}
